package com.wyth.lottery.fragment;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wyth.lottery.R;
import com.wyth.lottery.base.BaseFragment;
import com.wyth.lottery.bean.hezhi.HezhiTextBean;
import com.wyth.lottery.utils.MyApplication;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2017/11/2 0002.
 */

public class ThreeLianFragment extends BaseFragment {

    @BindView(R.id.rv_hezhi)
    RecyclerView rvHezhi;
    @BindView(R.id.tv_sum)
    TextView tvSum;
    @BindView(R.id.tv_3lianhao_123)
    TextView tv3lianhao123;
    @BindView(R.id.tv_3lianhao_234)
    TextView tv3lianhao234;
    @BindView(R.id.tv_3lianhao_345)
    TextView tv3lianhao345;
    @BindView(R.id.tv_3lianhao_456)
    TextView tv3lianhao456;
    @BindView(R.id.tv_3lianhao_all)
    TextView tv3lianhaoAll;
    @BindView(R.id.tv_notes_sum)
    TextView tvNotesSum;
    @BindView(R.id.tv_money_sum)
    TextView tvMoneySum;
    private boolean tv123Enable = true;
    private boolean tv234Enable = true;
    private boolean tv345Enable = true;
    private boolean tv456Enable = true;
    private boolean tvAllEnable = true;
    @Override
    protected View getSuccessView() {
        View view = LayoutInflater.from(MyApplication.getContext()).inflate(R.layout.fragment_qthree_3lianhao, null);
        return view;
    }

    @Override
    protected void initDate() {
        stateLayout.showSuccessView();
        initQThreeView();
    }

    private void initQThreeView() {
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(7, StaggeredGridLayoutManager.VERTICAL);
        rvHezhi.setLayoutManager(staggeredGridLayoutManager);
        ArrayList<HezhiTextBean> hezhiList = new ArrayList<>();


        hezhiList.add(new HezhiTextBean("4", "奖金80"));
        hezhiList.add(new HezhiTextBean("5", "奖金80"));
        hezhiList.add(new HezhiTextBean("6", "奖金80"));
        hezhiList.add(new HezhiTextBean("7", "奖金80"));
        hezhiList.add(new HezhiTextBean("8", "奖金80"));
        hezhiList.add(new HezhiTextBean("9", "奖金80"));
        hezhiList.add(new HezhiTextBean("10", "奖金80"));
        hezhiList.add(new HezhiTextBean("11", "奖金80"));
        hezhiList.add(new HezhiTextBean("12", "奖金80"));
        hezhiList.add(new HezhiTextBean("13", "奖金80"));
        hezhiList.add(new HezhiTextBean("14", "奖金80"));
        hezhiList.add(new HezhiTextBean("15", "奖金80"));
        hezhiList.add(new HezhiTextBean("16", "奖金80"));
        hezhiList.add(new HezhiTextBean("17", "奖金80"));
        HezhiAdapter redAdapter = new HezhiAdapter(hezhiList);
        rvHezhi.setAdapter(redAdapter);
    }


    @OnClick({R.id.tv_3lianhao_123, R.id.tv_3lianhao_234, R.id.tv_3lianhao_345, R.id.tv_3lianhao_456, R.id.tv_3lianhao_all})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_3lianhao_123:
                if (tv123Enable){
                    tv3lianhao123.setBackgroundResource(R.drawable.text_red_10_background);
                    tv3lianhao123.setTextColor(getResources().getColor(R.color.white));
                    tv123Enable = false;
                }else {
                    tv3lianhao123.setBackgroundResource(R.drawable.text_pink_10_background);
                    tv3lianhao123.setTextColor(getResources().getColor(R.color.colorTextSelect));
                    tv123Enable = true;
                }
                break;
            case R.id.tv_3lianhao_234:
                if (tv234Enable){
                    tv3lianhao234.setBackgroundResource(R.drawable.text_red_10_background);
                    tv3lianhao234.setTextColor(getResources().getColor(R.color.white));
                    tv234Enable = false;
                }else {
                    tv3lianhao234.setBackgroundResource(R.drawable.text_pink_10_background);
                    tv3lianhao234.setTextColor(getResources().getColor(R.color.colorTextSelect));
                    tv234Enable = true;
                }
                break;
            case R.id.tv_3lianhao_345:

                if (tv345Enable){
                    tv3lianhao345.setBackgroundResource(R.drawable.text_red_10_background);
                    tv3lianhao345.setTextColor(getResources().getColor(R.color.white));
                    tv345Enable = false;
                }else {
                    tv3lianhao345.setBackgroundResource(R.drawable.text_pink_10_background);
                    tv3lianhao345.setTextColor(getResources().getColor(R.color.colorTextSelect));
                    tv345Enable = true;
                }
                break;
            case R.id.tv_3lianhao_456:

                if (tv456Enable){
                    tv3lianhao456.setBackgroundResource(R.drawable.text_red_10_background);
                    tv3lianhao456.setTextColor(getResources().getColor(R.color.white));
                    tv456Enable = false;
                }else {
                    tv3lianhao456.setBackgroundResource(R.drawable.text_pink_10_background);
                    tv3lianhao456.setTextColor(getResources().getColor(R.color.colorTextSelect));
                    tv456Enable = true;
                }
                break;
            case R.id.tv_3lianhao_all:
                if (tvAllEnable){
                    tv3lianhaoAll.setBackgroundResource(R.drawable.text_red_10_background);
                    tv3lianhaoAll.setTextColor(getResources().getColor(R.color.white));
                    tv3lianhao123.setBackgroundResource(R.drawable.text_red_10_background);
                    tv3lianhao123.setTextColor(getResources().getColor(R.color.white));
                    tv3lianhao234.setBackgroundResource(R.drawable.text_red_10_background);
                    tv3lianhao234.setTextColor(getResources().getColor(R.color.white));
                    tv3lianhao345.setBackgroundResource(R.drawable.text_red_10_background);
                    tv3lianhao345.setTextColor(getResources().getColor(R.color.white));
                    tv3lianhao456.setBackgroundResource(R.drawable.text_red_10_background);
                    tv3lianhao456.setTextColor(getResources().getColor(R.color.white));
                    tvAllEnable = false;
                }else {
                    tv3lianhaoAll.setBackgroundResource(R.drawable.text_pink_10_background);
                    tv3lianhaoAll.setTextColor(getResources().getColor(R.color.colorTextSelect));
                    tv3lianhao123.setBackgroundResource(R.drawable.text_pink_10_background);
                    tv3lianhao123.setTextColor(getResources().getColor(R.color.colorTextSelect));
                    tv3lianhao234.setBackgroundResource(R.drawable.text_pink_10_background);
                    tv3lianhao234.setTextColor(getResources().getColor(R.color.colorTextSelect));
                    tv3lianhao345.setBackgroundResource(R.drawable.text_pink_10_background);
                    tv3lianhao345.setTextColor(getResources().getColor(R.color.colorTextSelect));
                    tv3lianhao456.setBackgroundResource(R.drawable.text_pink_10_background);
                    tv3lianhao456.setTextColor(getResources().getColor(R.color.colorTextSelect));
                    tvAllEnable = true;
                }
                break;
        }
    }

    class HezhiAdapter extends BaseQuickAdapter<HezhiTextBean, BaseViewHolder> {

        public HezhiAdapter(List<HezhiTextBean> data) {
            super(R.layout.layout_hezhi, data);
        }

        @Override
        protected void convert(final BaseViewHolder helper, final HezhiTextBean item) {
            helper.setText(R.id.tv_hezhi, item.getHezhi());
            helper.setText(R.id.tv_jiangjin, item.getJiangjin());
        }
    }
}
